<?php

namespace app\admin\controller\kzvote;

use app\common\controller\Backend;
use think\Config;

/**
 * 链接选择器
 */
class Link extends Backend
{

    protected $noNeedLogin = ['index'];
    protected $noNeedRight = ['*'];

    public function index(){
        if ($this->request->isAjax()) {
            $pages = [
                [
                    'name' => '系统首页',
                    'url' => '/pages/index/index',
                    'open_type' => 'redirect'
                ],
                [
                    'name' => '个人中心',
                    'url' => '/pages/user/user',
                    'open_type' => 'redirect'
                ],
                [
                    'name' => '发起投票',
                    'url' => '/pages/create/create',
                    'open_type' => 'redirect'
                ],
                [
                    'name' => '投票模板',
                    'url' => '/pages/temp/temp',
                    'open_type' => 'redirect'
                ],
                [
                    'name' => '投票活动',
                    'url' => '/pages/vote/index',
                    'open_type' => 'redirect',
                    'params' => [
                        [
                            'key' => 'vote_id',
                            'value' => '/',
                            'desc' => '投票ID'
                        ]
                    ],
                ],
                [
                    'name' => '选手页',
                    'url' => '/pages/vote/person',
                    'open_type' => 'redirect',
                    'params' => [
                        [
                            'key' => 'person_id',
                            'value' => '/',
                            'desc' => '选手ID'
                        ]
                    ],
                ],
                [
                    'name' => '排行榜',
                    'url' => '/pages/vote/rank',
                    'open_type' => 'redirect',
                    'params' => [
                        [
                            'key' => 'vote_id',
                            'value' => '/',
                            'desc' => '投票ID'
                        ]
                    ],
                ],
                [
                    'name' => '投票规则',
                    'url' => '/pages/vote/rule',
                    'open_type' => 'redirect',
                    'params' => [
                        [
                            'key' => 'vote_id',
                            'value' => '/',
                            'desc' => '投票ID'
                        ]
                    ],
                ],
                [
                    'name' => '二选一投票',
                    'url' => '/pages/vote/pk',
                    'open_type' => 'redirect',
                    'params' => [
                        [
                            'key' => 'vote_id',
                            'value' => '/',
                            'desc' => '投票ID'
                        ]
                    ],
                ],
                [
                    'name' => '内部路径',
                    'url' => '',
                    'open_type' => 'path',
                    'params' => [
                        [
                            'key' => 'url',
                            'value' => '/',
                            'desc' => '小程序路径'
                        ]
                    ],
                ],
                [
                    'name' => '跳转小程序',
                    'url' => 'wxapp',
                    'open_type' => 'wxapp',
                    'params' => [
                        [
                            'key' => 'appid',
                            'value' => '',
                            'desc' => '小程序appid'
                        ],
                        [
                            'key' => 'path',
                            'value' => '',
                            'desc' => '页面路径'
                        ],
                    ],
                ],
                [
                    'name' => '跳转网页',
                    'url' => 'url',
                    'open_type' => 'web',
                    'params' => [
                        [
                            'key' => 'url',
                            'value' => '',
                            'desc' => '网页链接'
                        ]
                    ],
                ],
                [
                    'name' => '拨打电话',
                    'url' => 'tel',
                    'open_type' => 'tel',
                    'params' => [
                        [
                            'key' => 'tel',
                            'value' => '',
                            'desc' => '手机号码'
                        ]
                    ],
                ],
                [
                    'name' => '联系客服',
                    'url' => 'contact',
                    'open_type' => 'contact'
                ],
            ];
            $result = array("total" => count($pages), "rows" => $pages);

            return json($result);
        }

        return $this->view->fetch();
    }


}
